home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 49
/
Aminet 49 (2002)(GTI - Schatztruhe)[!][Jun 2002].iso
/
Aminet
/
util
/
misc
/
ReportPlus.lha
/
ReportPlus
/
source
/
f4.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-04-15
|
69KB
|
1,638 lines
#include <exec/types.h>
#include <exec/memory.h>
#include <proto/exec.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <proto/intuition.h>
#include <libraries/gadtools.h>
#include <proto/gadtools.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "rp.h"
#define ALL_REACTION_CLASSES
#include <reaction/reaction.h>
#include <clib/texteditor_protos.h>
#include <gadgets/texteditor.h>
#include <pragmas/texteditor_pragmas.h>
#define MAXELEMENTS_4 14 // counting from 0
MODULE void bizarre(void);
MODULE void updateautodocgadgets(void);
MODULE void readautodocgadgets(void);
MODULE void starify(STRPTR buffer);
MODULE void destarify(STRPTR buffer);
MODULE ULONG parseeither(STRPTR terminator1, STRPTR terminator2);
MODULE void numberofinputs(void);
MODULE UBYTE* StarBufferPtr = NULL;
MODULE ULONG elements,
returncode,
inputs;
MODULE struct Gadget* autodoc_gadgets[GIDS_4 + 1];
/* Current limitations:
* 4K characters per text editor field. This limitation is
not currently enforced by the program. Ideally we would like to use
TEXTEDITOR_MaxChars or suchlike. Using strncpy() with a limit of 4K
when reading from the text editor gadgets or reading from a file would
also be good.
* 16K characters for the entire autodoc. */
AGLOBAL struct AutodocStruct autodoc;
IMPORT struct Menu* MenuPtr;
IMPORT Object* WinObject[FUNCTIONS + 1];
IMPORT struct Screen* ScreenPtr;
IMPORT struct Window* MainWindowPtr;
IMPORT struct SharedStruct shared;
IMPORT struct Library* TextEditorBase;
IMPORT SBYTE page;
IMPORT TEXT aslresult[MEDFIELD + 1],
IOBuffer[LONGESTFIELD + 1],
string[VLONGFIELD + 1];
IMPORT ULONG offset;
AGLOBAL void autodoc1(void)
{ struct Hook Hook4Struct;
/* Create the window object. */
lockscreen();
gadtools();
InitHook(&Hook4Struct, Hook4Func, NULL);
if (!(WinObject[4] =
NewObject
( WINDOW_GetClass(), NULL,
WA_PubScreen, ScreenPtr,
WA_ScreenTitle, "Report+",
WA_Title, "Report+: Autodoc Editor (Page 1 of 2)",
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WA_IDCMP, IDCMP_RAWKEY,
WINDOW_IDCMPHook, &Hook4Struct,
WINDOW_IDCMPHookBits, IDCMP_RAWKEY,
WINDOW_MenuStrip, MenuPtr,
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, autodoc_gadgets[GID_4_LY1] =
NewObject
( LAYOUT_GetClass(), NULL,
// root-layout
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_DeferLayout, TRUE,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "modulename._type:",
LABEL_Justification,LJ_LEFT,
TAG_END),
CHILD_WeightedHeight, 0,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Function_Name:",
LABEL_Justification,LJ_LEFT,
TAG_END),
CHILD_WeightedHeight, 0,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "_Description:",
LABEL_Justification,LJ_LEFT,
TAG_END),
CHILD_WeightedHeight, 0,
TAG_END),
CHILD_WeightedWidth, 0,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST1] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST1,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.library,
STRINGA_MinVisible,15,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
CHILD_WeightedWidth, 50,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Minimum _version:",
LABEL_Justification,LJ_LEFT,
TAG_END),
CHILD_WeightedWidth, 0,
LAYOUT_AddChild, autodoc_gadgets[GID_4_IN1] =
NewObject
( INTEGER_GetClass(), NULL,
GA_ID, GID_4_IN1,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
INTEGER_Number, autodoc.version,
INTEGER_Minimum, 0, // ULONG (maximum value is (2^32) - 1)
INTEGER_MinVisible, 5,
TAG_END
),
CHILD_WeightedWidth, 50,
TAG_END),
CHILD_WeightedHeight, 0,
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST2] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST2,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.funcname,
STRINGA_MinVisible,35,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
CHILD_WeightedHeight, 0,
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST3] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST3,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.description,
STRINGA_MinVisible,35,
STRINGA_MaxChars, VLONGFIELD,
TAG_END),
CHILD_WeightedHeight, 0,
TAG_END),
CHILD_WeightedWidth, 100,
TAG_END),
CHILD_WeightedHeight, 0,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_LEFT,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "_Return code:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _1:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _2:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _3:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _4:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _5:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _6:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _7:",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Argument _8:",
LABEL_Justification,LJ_CENTER,
TAG_END),
TAG_END),
CHILD_WeightedWidth, 0,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Type",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST4] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST4,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[0].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST5] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST5,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[1].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST6] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST6,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[2].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST7] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST7,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[3].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST8] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST8,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[4].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST9] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST9,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[5].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST10] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST10,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[6].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST11] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST11,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[7].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST12] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST12,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[8].type,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
TAG_END),
CHILD_WeightedWidth, 35,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Name",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST13] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST13,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[0].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST14] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST14,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[1].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST15] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST15,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[2].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST16] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST16,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[3].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST17] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST17,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[4].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST18] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST18,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[5].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST19] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST19,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[6].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST20] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST20,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[7].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST21] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST21,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[8].name,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
TAG_END),
CHILD_WeightedWidth, 50,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddImage,
NewObject
( LABEL_GetClass(), NULL,
LABEL_Text, "Register",
LABEL_Justification,LJ_CENTER,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST22] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST22,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[0].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST23] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST23,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[1].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST24] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST24,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[2].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST25] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST25,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[3].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST26] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST26,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[4].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST27] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST27,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[5].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST28] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST28,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[6].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST29] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST29,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[7].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
LAYOUT_AddChild, autodoc_gadgets[GID_4_ST30] =
NewObject
( STRING_GetClass(), NULL,
GA_ID, GID_4_ST30,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_TextVal, autodoc.var[8].reg,
STRINGA_MinVisible,8,
STRINGA_MaxChars, MEDFIELD,
TAG_END),
TAG_END),
CHILD_WeightedWidth, 15,
TAG_END),
CHILD_WeightedHeight, 0,
LAYOUT_AddChild, autodoc_gadgets[GID_4_BU1] =
NewObject
( NULL, "button.gadget",
// button
GA_ID, GID_4_BU1,
GA_RelVerify, TRUE,
GA_Text, "_Other page",
TAG_END),
CHILD_WeightedHeight, 0,
TAG_END
))))
{ rq("Can't create ReAction objects!");
}
unlockscreen();
openwindow();
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_NEW, NOSUB));
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_OPEN, NOSUB));
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE, NOSUB));
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
ActivateLayoutGadget(autodoc_gadgets[GID_4_LY1], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_ST1]);
loop();
closewindow();
}
AGLOBAL void saveautodoc(ABOOL saveas)
{ ULONG i, j;
TEXT temp[MEDFIELD + 1];
SWORD size;
readautodocgadgets();
strcpy(IOBuffer, "/" "****** "); // 1: "/###### "
strcat(IOBuffer, autodoc.library); // 1: "/###### <library>"
strcat(IOBuffer, "/"); // 1: "/###### <library>/"
strcat(IOBuffer, autodoc.funcname); // 1: "/###### <library>/<funcname>"
strcat(IOBuffer, " "); // 1: "/###### <library>/<funcname> "
size = 67 - strlen(autodoc.library) - strlen(autodoc.funcname);
if (size > 0)
{ for (i = 1; i <= size; i++)
strcat(IOBuffer, "*"); // 1: "/###### <library>/<funcname> <stars>"
}
strcat(IOBuffer, "\n*\n* NAME\n* ");
// 1: "/###### <library>/<funcname> <stars>\n"
// 2: "#\n"
// 3: "# NAME\n"
// 4: "# "
strcat(IOBuffer, autodoc.funcname); // 4: "# <funcname>"
strcat(IOBuffer, " -- "); // 4: "# <funcname> -- "
strcat(IOBuffer, autodoc.description);
// 4: "# <funcname> -- <description>"
if (autodoc.version)
{ strcat(IOBuffer, " (V"); // 4: "# <funcname> -- <description>[ (V]"
stcl_d(temp, autodoc.version);
strcat(IOBuffer, temp); // 4: "# <funcname> -- <description>[ (V<version>]"
strcat(IOBuffer, ")"); // 4: "# <funcname> -- <description>[ (V<version>)]
}
strcat(IOBuffer, "\n*\n* SYNOPSIS\n");
// 4: "# <funcname> -- <description>[ (V<version>)]\n"
// 5: "#\n"
// 6: "# SYNOPSIS\n"
// name line
strcat(IOBuffer, "* "); // 7: "# "
if (autodoc.var[0].name[0])
{ strcat(IOBuffer, autodoc.var[0].name);
// 7: "# [<returnname>]"
strcat(IOBuffer, " = "); // 7: "# [<returnname> = ]"
}
strcat(IOBuffer, autodoc.funcname); // 7: "# [<returnname> = ]<funcname>"
strcat(IOBuffer, "("); // 7: "# [<returnname> = ]<funcname>("
for (i = 1; i <= 8; i++)
{ if (autodoc.var[i].name[0])
{ if (i >= 2)
strcat(IOBuffer, ", ");
strcat(IOBuffer, autodoc.var[i].name);
size = strlen(autodoc.var[i].reg) - strlen(autodoc.var[i].name);
if (size > 0)
for (j = 1; j <= size; j++)
strcat(IOBuffer, " ");
} else break;
}
strcat(IOBuffer, ")\n"); // 7: "# [<returnname> = ]<funcname>([<arglist>])\n"
// register line
strcat(IOBuffer, "* "); // 8: "# "
if (autodoc.var[0].reg[0] && autodoc.var[0].name[0])
{ strcat(IOBuffer, autodoc.var[0].reg);
// 8: "# [<returnreg>]"
size = strlen(autodoc.var[0].name) - strlen(autodoc.var[0].reg);
if (size > 0)
for (i = 1; i <= size; i++)
strcat(IOBuffer, " "); // 8: "# [<returnreg><spaces>]"
strcat(IOBuffer, " "); // 8: "# [<returnreg><spaces> ]"
}
size = strlen(autodoc.funcname);
if (size >= 0) // this is no mistake
for (i = 0; i <= size; i++)
strcat(IOBuffer, " "); // 8: "# [<returnreg><spaces> ]<spaces>"
for (i = 1; i <= 8; i++)
{ if (autodoc.var[i].reg[0])
{ if (i >= 2)
strcat(IOBuffer, " ");
strcat(IOBuffer, autodoc.var[i].reg);
size = strlen(autodoc.var[i].name) - strlen(autodoc.var[i].reg);
if (size > 0)
for (j = 1; j <= size; j++)
strcat(IOBuffer, " ");
} }
strcat(IOBuffer, "\n"); // 8: "# [<returnreg><spaces> ]<spaces>[<reglist>]\n"
strcat(IOBuffer, "*\n* "); // 9: "#\n"
// 10: "# "
if (autodoc.var[0].type[0])
{ strcat(IOBuffer, autodoc.var[0].type);
// 10a: "# <returntype>"
strcat(IOBuffer, " "); // 10a: "# <returntype> "
} else
strcat(IOBuffer, "void "); // 10b: "# void "
strcat(IOBuffer, autodoc.funcname); // 10: "# <returntype>|void <funcname>"
strcat(IOBuffer, "("); // 10: "# <returntype>|void <funcname>("
if (!(autodoc.var[1].type)) // 10: "# <returntype>|void <funcname>([void]"
strcat(IOBuffer, "void");
else
{ for (i = 1; i <= 8; i++)
{ if (autodoc.var[i].type[0])
{ if (i >= 2)
strcat(IOBuffer, ", ");
strcat(IOBuffer, autodoc.var[i].type);
} else break;
} }
strcat(IOBuffer, ");\n*\n* FUNCTION\n* ");
// 10: "# <returntype>|void <funcname>(void|<typelist>);\n"
// 11: "#\n"
// 12: "# FUNCTION\n"
// 13: "# "
starify(autodoc.function);
strcat(IOBuffer, StarBufferPtr); // 13: "# <buffer>"
FreeVec(StarBufferPtr);
strcat(IOBuffer, "\n*\n* INPUTS\n"); // 13: "# <buffer>\n"
// 14: "#\n"
// 15: "# INPUTS\n"
bizarre();
strcat(IOBuffer, "*\n* RESULT\n* ");
// 17: "#\n"
// 18: "# RESULT\n"
// 19: "# "
if (!(autodoc.var[0].name[0]))
{ strcat(IOBuffer, "NONE"); // 19a: "# NONE"
} else
{ strcat(IOBuffer, autodoc.var[0].name);
// 19b: "# <returnname>"
strcat(IOBuffer, " - "); // 19b: "# <returnname> - "
starify(autodoc.var[0].desc);
strcat(IOBuffer, StarBufferPtr); // 19b: "# <returnname> - <buffer>"
FreeVec(StarBufferPtr);
}
strcat
( IOBuffer,
"\n*\n" // 19a: "# NONE\n"
// 19b: "# <returnname> - <buffer>\n"
// 20: "#\n"
"* EXAMPLE\n* " // 21: "# EXAMPLE\n"
// 22: "# "
);
starify(autodoc.example);
strcat(IOBuffer, StarBufferPtr); // 22: "# <buffer>"
FreeVec(StarBufferPtr);
strcat(IOBuffer, "\n*\n* NOTES\n* ");
// 22: "# <buffer>\n"
// 23: "#\n"
// 24: "# NOTES\n"
// 25: "# "
starify(autodoc.notes);
strcat(IOBuffer, StarBufferPtr); // 25: "# <buffer>"
FreeVec(StarBufferPtr);
strcat(IOBuffer, "\n*\n* BUGS\n* ");
// 25: "# <buffer>\n"
// 26: "#\n"
// 27: "# BUGS\n"
// 28: "# "
starify(autodoc.bugs);
strcat(IOBuffer, StarBufferPtr); // 28: "# <buffer>"
FreeVec(StarBufferPtr);
strcat(IOBuffer, "\n*\n* SEE ALSO\n* ");
// 28: "# <buffer>\n"
// 29: "#\n"
// 30: "# SEE ALSO\n"
// 31: "# "
starify(autodoc.seealso);
strcat(IOBuffer, StarBufferPtr); // 31: "# <buffer>"
FreeVec(StarBufferPtr);
strcat
( IOBuffer,
"\n*\n" // 31: "# <buffer>\n"
// 32: "#\n"
"*****************************************************************************\n"
// 33: "<77 stars>\n"
"*\n*" // 34: "#\n"
// 35: "#"
"/\n" // 35: "#/\n"
);
if (!autodoc.output[0] || saveas) // if we need a filename
{ if (saveasl("Save Autodoc", "#?.c"))
{ strcpy(autodoc.output, aslresult);
writeout(autodoc.output);
} }
else
{ writeout(autodoc.output);
} }
MODULE void bizarre(void)
{ ULONG i, j;
SWORD size, longest = 0, thislength; // must be signed
TEXT line[VLONGFIELD + 1]; // better not make it too large, as it is
// a local (stack) variable.
numberofinputs();
if (!inputs)
{ strcpy(line, "* NONE\n"); // 16: "# NONE\n"
} else
{ for (i = 1; i <= inputs; i++)
{ thislength = strlen(autodoc.var[i].name);
if (thislength > longest)
{ longest = thislength;
} }
for (i = 1; i <= inputs; i++)
{ strcpy(line, "* "); // 16: "# "
strcat(line, autodoc.var[i].name);
// 16: "# <argname1>"
thislength = strlen(autodoc.var[i].name);
size = longest - thislength;
if (size > 0)
{ for (j = 1; j <= size; j++)
{ strcat(line, " "); // 16: "# <argname1><spaces>"
} }
strcat(line, " - "); // 16: "# <argname1><spaces> - "
starify(autodoc.var[i].desc);
strcat(line, StarBufferPtr);
FreeVec(StarBufferPtr); // 16: "# <argname1><spaces> - <buffer1>"
strcat(line, "\n"); // 16: "# <argname1><spaces> - <buffer1>\n"
strcat(IOBuffer, line);
} } }
AGLOBAL void newautodoc(ABOOL display)
{ ULONG i;
autodoc.version = 0;
autodoc.library[0] = 0;
autodoc.funcname[0] = 0;
autodoc.description[0] = 0;
for (i = 0; i <= 8; i++)
{ autodoc.var[i].name[0] = 0;
autodoc.var[i].type[0] = 0;
autodoc.var[i].reg[0] = 0;
autodoc.var[i].desc[0] = 0;
}
autodoc.output[0] = 0;
autodoc.function[0] = 0;
autodoc.example[0] = 0;
autodoc.notes[0] = 0;
autodoc.bugs[0] = 0;
autodoc.seealso[0] = 0;
if (display)
{ updateautodocgadgets();
} }
AGLOBAL void openautodoc(void)
{ if (asl("~(#?.info)"))
{ newautodoc(FALSE); // This line and the next are order-dependant
strcpy(autodoc.output, aslresult);
loadautodoc();
updateautodocgadgets();
} }
AGLOBAL void loadautodoc(void)
{ ULONG counter, i, whatfound;
/* parse() returns when it has moved along and found the specified
`ending string'. The contents, since last parse(), before the
`ending string' are returned in string. */
if (readin(autodoc.output))
{ offset = 0;
parse("/" "****** "); // skip header
// name
parse("/");
strcpy(autodoc.library, string);
parse(" ");
strcpy(autodoc.funcname, string);
parse("\n*\n* NAME\n* ");
// ignore that, skip all the asterisks
parse(" -- ");
// function name is repeated here
if (parseeither(" (V", "\n*\n* SYNOPSIS\n* ") == 1)
{ strcpy(autodoc.description, string);
parse(")\n*\n* SYNOPSIS\n* ");
autodoc.version = atol(string);
} else
{ strcpy(autodoc.description, string);
}
// synopsis
if (parseeither(" = ", "(") == 1)
{ strcpy(autodoc.var[0].name, string);
parse("(");
}
// function name is repeated here
counter = 0;
while (whatfound = parseeither(", ", ")\n* "))
{ if (string[0]) // in case we get () situation (ie. no args)
{ counter++;
strcpy(autodoc.var[counter].name, string);
}
if (whatfound == 2)
{ break;
} }
inputs = counter;
if (autodoc.var[0].name[0])
{ counter = 0;
} else counter = 1; // where to start
while (whatfound = parseeither(" ", "\n*\n* "))
{ if (string[0])
{ strcpy(autodoc.var[counter].reg, string);
counter++;
}
if (whatfound == 2)
{ break;
} }
parse(" ");
strcpy(autodoc.var[0].type, string);
parse("(");
// function name is repeated here
counter = 0;
while (whatfound = parseeither(", ", ");\n*\n* FUNCTION\n* "))
{ if (string[0]) // in case we get () situation (ie. no args)
{ counter++;
strcpy(autodoc.var[counter].type, string);
}
if (whatfound == 2)
{ break;
} }
// function
parse("\n*\n* INPUTS\n* ");
destarify(string);
strcpy(autodoc.function, StarBufferPtr);
FreeVec(StarBufferPtr);
// inputs
for (i = 1; i <= inputs; i++)
{ parse(" ");
parse(" -");
// input name is repeated here
if (parseeither(" ", "\n*") == 1)
{ parse("\n*");
destarify(string);
strcpy(autodoc.var[counter].desc, StarBufferPtr);
FreeVec(StarBufferPtr);
} }
parse("\n* RESULT\n* ");
// result
if (parseeither(" - ", "NONE\n*\n* EXAMPLE\n* ") == 1)
{ strcpy(autodoc.var[0].name, string);
parse("\n*\n* EXAMPLE");
destarify(string);
strcpy(autodoc.var[0].desc, StarBufferPtr);
FreeVec(StarBufferPtr);
parseeither("\n* ", "S\n* "); // accepts either EXAMPLE or EXAMPLES
}
// example
parse("\n*\n* NOTES\n* ");
destarify(string);
strcpy(autodoc.example, StarBufferPtr);
FreeVec(StarBufferPtr);
// notes
parse("\n*\n* BUGS\n* ");
destarify(string);
strcpy(autodoc.notes, StarBufferPtr);
FreeVec(StarBufferPtr);
// bugs
parse("\n*\n* SEE ALSO\n* ");
destarify(string);
strcpy(autodoc.bugs, StarBufferPtr);
FreeVec(StarBufferPtr);
// see also
parse("\n*\n*****************************************************************************\n*\n*" "/" "\n");
destarify(string);
strcpy(autodoc.seealso, StarBufferPtr);
FreeVec(StarBufferPtr);
} }
AGLOBAL void autodoc_init(void)
{ newautodoc(FALSE);
}
AGLOBAL void autodoc_loop(ULONG gid)
{ STRPTR stringptr;
switch(gid)
{
case GID_4_ST1:
if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST1], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.library, stringptr);
break;
case GID_4_ST2:
if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST2], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.funcname, stringptr);
break;
case GID_4_ST3:
if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST3], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.description, stringptr);
break;
case GID_4_IN1:
if (!(GetAttr
( INTEGER_Number, autodoc_gadgets[GID_4_IN1], (ULONG *) &autodoc.version
)))
{ rq("Unsupported inquiry!"); // should never happen
}
break;
case GID_4_BU1:
readautodocgadgets();
numberofinputs();
page = 42;
break;
case GID_4_BU3:
readautodocgadgets();
page = 41;
break;
default:
if (gid >= GID_4_ST4 && gid <= GID_4_ST4 + 8)
{ if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[gid], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.var[gid - GID_4_ST4].type, stringptr);
} elif (gid >= GID_4_ST13 && gid <= GID_4_ST13 + 8)
{ if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[gid], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.var[gid - GID_4_ST13].name, stringptr);
} elif (gid >= GID_4_ST22 && gid <= GID_4_ST22 + 8)
{ if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[gid], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.var[gid - GID_4_ST22].reg, stringptr);
}
break;
} }
MODULE void updateautodocgadgets(void)
{ ULONG i;
if (page == 41)
{ SetGadgetAttrs
( autodoc_gadgets[GID_4_ST1], MainWindowPtr, NULL,
STRINGA_TextVal, autodoc.library,
TAG_END
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_ST2], MainWindowPtr, NULL,
STRINGA_TextVal, autodoc.funcname,
TAG_END
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_ST3], MainWindowPtr, NULL,
STRINGA_TextVal, autodoc.description,
TAG_END
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_IN1], MainWindowPtr, NULL,
INTEGER_Number, autodoc.version,
TAG_END
);
for (i = 0; i <= 8; i++)
{ SetGadgetAttrs
( autodoc_gadgets[GID_4_ST4 + i], MainWindowPtr, NULL,
STRINGA_TextVal, autodoc.var[i].type,
TAG_END
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_ST13 + i], MainWindowPtr, NULL,
STRINGA_TextVal, autodoc.var[i].name,
TAG_END
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_ST22 + i], MainWindowPtr, NULL,
STRINGA_TextVal, autodoc.var[i].reg,
TAG_END
);
} }
else
{ ; /* assert(page == 42);
This should never be called, because New and Open... are only
available from page 41. */
}
}
MODULE void readautodocgadgets(void)
{ ULONG i;
STRPTR stringptr;
STRPTR textBuffer[MAXELEMENTS_4 + 1];
if (page == 41)
{ if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST1], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.library, stringptr);
if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST2], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.funcname, stringptr);
if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST3], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.description, stringptr);
if (!(GetAttr
( INTEGER_Number, autodoc_gadgets[GID_4_IN1], (ULONG *) &autodoc.version
)))
{ rq("Unsupported inquiry!"); // should never happen
}
for (i = 0; i <= 8; i++)
{ if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST4 + i], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.var[i].type, stringptr);
if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST13 + i], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.var[i].name, stringptr);
if (!(GetAttr
( STRINGA_TextVal, autodoc_gadgets[GID_4_ST22 + i], (ULONG *) &stringptr
)))
{ rq("Unsupported inquiry!"); // should never happen
}
strcpy(autodoc.var[i].reg, stringptr);
} }
else
{ // assert(page == 42);
for (i = 0; i <= elements; i++)
{ textBuffer[i] = (STRPTR) DoGadgetMethod(autodoc_gadgets[GID_4_TE1 + i], MainWindowPtr, NULL, GM_TEXTEDITOR_ExportText, NULL);
}
strcpy(autodoc.function, textBuffer[0]);
if (inputs)
{ for (i = 1; i <= inputs; i++)
{ strcpy(autodoc.var[i].desc, textBuffer[i]);
} }
if (returncode)
{ strcpy(autodoc.var[0].desc, textBuffer[inputs + 1]);
}
strcpy(autodoc.example, textBuffer[inputs + returncode + 1]);
strcpy(autodoc.notes, textBuffer[inputs + returncode + 2]);
strcpy(autodoc.bugs, textBuffer[inputs + returncode + 3]);
strcpy(autodoc.seealso, textBuffer[inputs + returncode + 4]);
for (i = 0; i <= elements; i++)
{ FreeVec((APTR) textBuffer[i]);
textBuffer[i] = NULL;
} }
}
MODULE void starify(STRPTR buffer)
{ ULONG i, inputlength = 0, outputlength = 0, outputpos = 0;
ABOOL done = FALSE;
// first we count the number of LFs in the source buffer, and the
// length of the source buffer.
while (!done)
{ if (*(buffer + inputlength) == LF)
outputlength += 4;
elif (*(buffer + inputlength) == 0)
done = TRUE;
outputlength++;
inputlength++;
}
// now we allocate the buffer
if (!(StarBufferPtr = AllocVec(outputlength, MEMF_PUBLIC)))
rq("Out of memory!");
// now we translate into new buffer
for (i = 0; i <= inputlength; i++)
{ *(StarBufferPtr + outputpos) = *(buffer + i);
if (*(buffer + i) == LF)
{ *(StarBufferPtr + outputpos + 1) = '*';
*(StarBufferPtr + outputpos + 2) = ' ';
*(StarBufferPtr + outputpos + 3) = ' ';
*(StarBufferPtr + outputpos + 4) = ' ';
outputpos += 4;
}
outputpos++;
} }
MODULE void destarify(STRPTR buffer)
{ ULONG i, inputlength = 0, outputlength = 0, outputpos = 0;
ABOOL done = FALSE;
// Translates occurrences of "\n* " to " ".
while (!done) // first pass
{ if (!strncmp(buffer + inputlength, "\n* ", 5))
outputlength -= 4; // we replace 5 bytes with 1, saving 4 bytes
elif (*(buffer + inputlength) == 0)
done = TRUE;
outputlength++;
inputlength++;
}
// now we allocate the buffer
if (!(StarBufferPtr = AllocVec(outputlength, MEMF_PUBLIC)))
rq("Out of memory!");
// now we translate into new buffer
for (i = 0; i <= inputlength; i++) // second pass
{ if (!strncmp(buffer + i, "\n* ", 5))
{ // currently we are at the LF.
*(StarBufferPtr + outputpos) = ' ';
i += 4; // plus the usual 1 incremented by the loop
} else
{ *(StarBufferPtr + outputpos) = *(buffer + i);
}
outputpos++;
} }
AGLOBAL ULONG Hook4Func(struct Hook *h, VOID *o, VOID *msg)
{ /* "When the hook is called, the data argument points to the
window object and message argument to the IntuiMessage." */
UWORD code, qual;
geta4(); // wait till here before doing anything
code = ((struct IntuiMessage *) msg)->Code;
qual = ((struct IntuiMessage *) msg)->Qualifier;
switch(code)
{
case SCAN_HELP:
helpabout();
break;
case SCAN_ESCAPE:
if ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT))
{ cleanexit(EXIT_SUCCESS);
} else
{ page = 0;
}
break;
case SCAN_B:
if (page == 42)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY2], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_TE1 + inputs + returncode + 3]);
}
break;
case SCAN_D:
if (page == 41)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY1], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_ST3]);
}
break;
case SCAN_E:
if (page == 42)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY2], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_TE1 + inputs + returncode + 1]);
}
break;
case SCAN_F:
if (page == 42)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY2], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_TE1]);
}
break;
case SCAN_N:
if (page == 41)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY1], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_ST2]);
} else
{ // assert(page == 42);
ActivateLayoutGadget(autodoc_gadgets[GID_4_LY2], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_TE1 + inputs + returncode + 2]);
}
break;
case SCAN_T:
if (page == 41)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY1], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_ST1]);
}
break;
case SCAN_R:
if (page == 41)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY1], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_ST4]);
} else
{ // assert(page == 42);
if (returncode)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY2], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_TE1 + inputs + 1]);
} }
break;
case SCAN_S:
if (page == 42)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY2], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_TE1 + inputs + returncode + 4]);
}
break;
case SCAN_V:
if (page == 41)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY1], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_IN1]);
}
break;
default:
if (page == 41 && code >= SCAN_1 && code <= SCAN_8)
{ ActivateLayoutGadget(autodoc_gadgets[GID_4_LY1], MainWindowPtr, NULL, (Object) autodoc_gadgets[code - SCAN_1 + GID_4_ST5]);
}
break;
}
return(1);
}
AGLOBAL void autodoc2(void)
{ struct Hook Hook4Struct;
TEXT GadTitle[MAXELEMENTS_4 + 1][VLONGFIELD + 1];
ULONG i, counter;
struct TagItem tag_texteditor[4] =
{ { GA_ID, NULL }, // ti_Data filled later
{ GA_RelVerify, TRUE },
{ GA_TEXTEDITOR_ExportWrap, 72, },
{ TAG_END, NULL },
}, tag_subcaption[3] =
{ { LABEL_Text, NULL }, // ti_Data filled later
{ LABEL_Justification, LJ_CENTRE },
{ TAG_END, NULL },
}, tag_button[4] =
{ { GA_ID, GID_4_BU3 },
{ GA_RelVerify, TRUE },
{ GA_Text, (ULONG) "_Other page" },
{ TAG_END, NULL }
}, tag_supercaption[7] =
{ { LAYOUT_Orientation, LAYOUT_ORIENT_VERT },
{ LAYOUT_SpaceOuter, TRUE },
{ LAYOUT_VertAlignment, LALIGN_CENTER },
{ LAYOUT_HorizAlignment, LALIGN_CENTER },
{ LAYOUT_BevelStyle, BVS_NONE },
{ LAYOUT_AddImage, NULL }, // ti_Data filled later
{ TAG_END, NULL }
}, tag_leftlayout[28] =
{ { LAYOUT_Orientation, LAYOUT_ORIENT_VERT },
{ LAYOUT_SpaceOuter, TRUE },
{ LAYOUT_DeferLayout, TRUE },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ TAG_END, NULL },
}, tag_rightlayout[25] =
{ { LAYOUT_Orientation, LAYOUT_ORIENT_VERT },
{ LAYOUT_SpaceOuter, TRUE },
{ LAYOUT_DeferLayout, TRUE },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ TAG_END, NULL },
}, tag_bothlayout[8] =
{ { LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ },
{ LAYOUT_SpaceOuter, TRUE },
{ LAYOUT_DeferLayout, TRUE },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedWidth, 50 },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedWidth, 50 },
{ TAG_END, NULL }
}, tag_rootlayout[7] =
{ { LAYOUT_Orientation, LAYOUT_ORIENT_VERT },
{ LAYOUT_SpaceOuter, TRUE },
{ LAYOUT_DeferLayout, TRUE },
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ LAYOUT_AddChild, NULL }, // ti_Data filled later
{ CHILD_WeightedHeight, 0 },
{ TAG_END, NULL }
}, tag_window[15] =
{ { WA_PubScreen, NULL }, // ti_Data filled later
{ WA_ScreenTitle, (ULONG) "Report+" },
{ WA_Title, (ULONG) "Report+: Autodoc Editor (Page 2 of 2)" },
{ WA_Activate, TRUE },
{ WA_DepthGadget, TRUE },
{ WA_DragBar, TRUE },
{ WA_CloseGadget, TRUE },
{ WA_SizeGadget, TRUE },
{ WA_IDCMP, IDCMP_RAWKEY },
{ WINDOW_IDCMPHook, NULL }, // ti_Data filled later
{ WINDOW_IDCMPHookBits, IDCMP_RAWKEY },
{ WINDOW_MenuStrip, NULL }, // ti_Data filled later
{ WINDOW_Position, WPOS_FULLSCREEN },
{ WINDOW_ParentGroup, NULL }, // ti_Data filled later
{ TAG_END, NULL }
};
strcpy(GadTitle[0], "_Function:");
if (inputs)
{ for (i = 1; i <= inputs; i++)
{ strcpy(GadTitle[i], autodoc.var[i].name);
strcat(GadTitle[i], ":");
} }
if (returncode)
{ strcpy(GadTitle[inputs + 1], "_Result:");
}
strcpy(GadTitle[inputs + 1 + returncode], "_Example:");
strcpy(GadTitle[inputs + 2 + returncode], "_Notes:");
strcpy(GadTitle[inputs + 3 + returncode], "_Bugs:");
strcpy(GadTitle[inputs + 4 + returncode], "_See Also:");
/* window
root-layout
both-layout
left-layout
super-caption
sub-caption
texteditor
right-layout
super-caption
sub-caption
texteditor
button
button */
counter = 3;
for (i = 0; i <= elements / 2; i++)
{ tag_subcaption[0].ti_Data = (ULONG) GadTitle[i];
tag_texteditor[0].ti_Data = GID_4_TE1 + i;
tag_supercaption[5].ti_Data = (ULONG) NewObjectA(LABEL_GetClass(), NULL, tag_subcaption);
tag_leftlayout[counter].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, tag_supercaption);
counter += 2;
tag_leftlayout[counter].ti_Data =
autodoc_gadgets[GID_4_TE1 + i] = (ULONG) NewObjectA(TEXTEDITOR_GetClass(), NULL, tag_texteditor);
counter++;
}
tag_leftlayout[counter].ti_Tag = TAG_END;
counter = 3;
for (i = (elements / 2) + 1; i <= elements; i++)
{ tag_subcaption[0].ti_Data = (ULONG) GadTitle[i];
tag_texteditor[0].ti_Data = GID_4_TE1 + i;
tag_supercaption[5].ti_Data = (ULONG) NewObjectA(LABEL_GetClass(), NULL, tag_subcaption);
tag_rightlayout[counter].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, tag_supercaption);
counter += 2;
tag_rightlayout[counter].ti_Data =
autodoc_gadgets[GID_4_TE1 + i] = (ULONG) NewObjectA(TEXTEDITOR_GetClass(), NULL, tag_texteditor);
counter++;
}
tag_rightlayout[counter].ti_Tag = TAG_END;
tag_bothlayout[3].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, tag_leftlayout);
tag_bothlayout[5].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, tag_rightlayout);
tag_rootlayout[3].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, tag_bothlayout);
tag_rootlayout[4].ti_Data =
autodoc_gadgets[GID_4_BU3] = (ULONG) NewObjectA(NULL, "button.gadget", tag_button);
tag_window[13].ti_Data =
autodoc_gadgets[GID_4_LY2] = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, tag_rootlayout);
InitHook(&Hook4Struct, Hook4Func, NULL);
tag_window[9].ti_Data = &Hook4Struct;
lockscreen();
tag_window[0].ti_Data = (ULONG) ScreenPtr;
gadtools();
tag_window[11].ti_Data = MenuPtr;
WinObject[4] = (ULONG) NewObjectA(WINDOW_GetClass(), NULL, tag_window);
unlockscreen();
if (!WinObject[4]) // Object creation successful?
{ rq("Can't create ReAction objects!");
}
openwindow();
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE, NOSUB));
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
/* New and Open... are not permitted from pages 14 and 42, since the
opened document might need a different number of text editor
gadgets. */
// Do any necessary imports.
SetGadgetAttrs
( autodoc_gadgets[GID_4_TE1], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, autodoc.function
);
if (inputs)
{ for (i = 1; i <= inputs; i++)
{ SetGadgetAttrs
( autodoc_gadgets[GID_4_TE1 + i], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, autodoc.var[i].desc
);
} }
if (returncode)
{ SetGadgetAttrs
( autodoc_gadgets[GID_4_TE1 + inputs + 1], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, autodoc.var[0].desc
); // return code
}
SetGadgetAttrs
( autodoc_gadgets[GID_4_TE1 + inputs + returncode + 1], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, autodoc.example
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_TE1 + inputs + returncode + 2], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, autodoc.notes
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_TE1 + inputs + returncode + 3], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, autodoc.bugs
);
SetGadgetAttrs
( autodoc_gadgets[GID_4_TE1 + inputs + returncode + 4], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, autodoc.seealso
);
ActivateLayoutGadget(autodoc_gadgets[GID_4_LY2], MainWindowPtr, NULL, (Object) autodoc_gadgets[GID_4_TE1]);
loop();
closewindow();
}
MODULE ULONG parseeither(STRPTR terminator1, STRPTR terminator2)
{ ULONG dest = 0; // index in destination string
/* When this returns, offset points just past the end of the terminator
string. string contains what was found before the terminator string. */
while (1)
{ if (IOBuffer[offset] != CR)
{ string[dest] = IOBuffer[offset];
}
if (!strncmp(&IOBuffer[offset], terminator1, strlen(terminator1)))
{ string[dest] = 0;
offset += strlen(terminator1);
return(1);
} elif (!strncmp(&IOBuffer[offset], terminator2, strlen(terminator2)))
{ string[dest] = 0;
offset += strlen(terminator2);
return(2);
} elif (offset > strlen(IOBuffer)) // we are past the end of the buffer
{ string[0] = 0;
return(0);
} else
{ offset++;
if (IOBuffer[offset] != CR)
{ dest++;
} } } }
MODULE void numberofinputs(void)
{ ULONG i;
if (autodoc.var[0].name[0])
returncode = 1; // non-boolean as it's used mathematically
else returncode = 0;
inputs = 0;
for (i = 1; i <= 8; i++)
{ if (autodoc.var[i].name[0])
inputs++;
else break;
}
elements = inputs + 4 + returncode;
}